﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:ctrl="clr-namespace:MediaOwl.Common.ControlTemplates;assembly=MediaOwl.Common"
             x:Class="MediaOwl.Netflix.Views.MovieTitleSingleView"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="400">

    <ctrl:WorkitemControl BusyContext="{Binding CurrentBusyViewModel}"
                          DialogContext="{Binding ActiveDialog}">
        <toolkit:DockPanel x:Name="LayoutRoot"
                           Margin="5">
            <StackPanel Orientation="Horizontal"
                        d:LayoutOverrides="Height"
                        toolkit:DockPanel.Dock="Top"
                        Margin="0,0,0,15">
                <TextBlock TextWrapping="Wrap"
                           Text="Detail:"
                           Style="{StaticResource Heading2}"
                           d:LayoutOverrides="Width"
                           Margin="0,0,10,0" />
                <TextBlock x:Name="DisplayName"
                           TextWrapping="Wrap"
                           Style="{StaticResource Heading2}" />
            </StackPanel>
            <Border BorderBrush="{StaticResource ControlBorderBrush}"
                    BorderThickness="1"
                    toolkit:DockPanel.Dock="Bottom"
                    Margin="10,15,10,10"
                    CornerRadius="3"
                    Background="{StaticResource DarkInnerShadowDarkBrush}"
                    Padding="5">
                <Button x:Name="TryClose"
                        Content="Close"
                        HorizontalAlignment="Right" />
            </Border>
            <sdk:TabControl toolkit:DockPanel.Dock="Top"
                            Margin="10,0">
                <sdk:TabItem Header="Information">
                    <ScrollViewer Margin="-5,-4"
                                  Style="{StaticResource CustomScrollViewerStyle}"
                                  ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <toolkit:DockPanel Margin="5">
                            <Grid toolkit:DockPanel.Dock="Top">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock TextWrapping="Wrap"
                                           Text="Name"
                                           Margin="5"
                                           VerticalAlignment="Center"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBlock HorizontalAlignment="Left"
                                           TextWrapping="Wrap"
                                           Text="Type"
                                           VerticalAlignment="Center"
                                           Grid.Row="1"
                                           Margin="5"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBlock HorizontalAlignment="Left"
                                           TextWrapping="Wrap"
                                           Text="Release Year"
                                           VerticalAlignment="Center"
                                           Grid.Row="2"
                                           Margin="5"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBlock HorizontalAlignment="Left"
                                           TextWrapping="Wrap"
                                           Text="Website"
                                           VerticalAlignment="Center"
                                           Grid.Row="3"
                                           Margin="5,5,0,5"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBlock HorizontalAlignment="Left"
                                           TextWrapping="Wrap"
                                           VerticalAlignment="Center"
                                           Grid.Row="4"
                                           Margin="5,5,0,5"
                                           Foreground="{StaticResource ControlForeground}"><Run Text="MPAA-" /><Run Text="Rating" /></TextBlock>
                                <TextBlock HorizontalAlignment="Left"
                                           TextWrapping="Wrap"
                                           Text="Rating"
                                           VerticalAlignment="Center"
                                           Grid.Row="5"
                                           Margin="5,5,0,5"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBox Grid.Column="1"
                                         d:LayoutOverrides="Width"
                                         IsReadOnly="True"
                                         Margin="5,2"
                                         Text="{Binding CurrentTitle.Name}" />
                                <TextBox Text="{Binding CurrentTitle.Type}"
                                         d:LayoutOverrides="Width"
                                         Grid.Row="1"
                                         Grid.Column="1"
                                         Margin="5,2"
                                         IsReadOnly="True" />
                                <TextBox Text="{Binding CurrentTitle.ReleaseYear}"
                                         Grid.Row="2"
                                         Grid.Column="1"
                                         Margin="5,2"
                                         IsReadOnly="True"
                                         d:LayoutOverrides="Width" />
                                <Border Grid.Column="1"
                                        Margin="5,2"
                                        Grid.Row="3"
                                        CornerRadius="2"
                                        Background="{StaticResource DarkInnerShadowDarkBrush}"
                                        BorderThickness="1"
                                        BorderBrush="{StaticResource DarkBorder}"
                                        d:LayoutOverrides="Width">
                                    <HyperlinkButton Content="{Binding CurrentTitle.TinyUrl}"
                                                     NavigateUri="{Binding CurrentTitle.TinyUrl}"
                                                     HorizontalAlignment="Left"
                                                     Margin="5,6,5,2"
                                                     VerticalAlignment="Center" />
                                </Border>
                                <TextBox Text="{Binding CurrentTitle.Rating}"
                                         Grid.Row="4"
                                         Grid.Column="1"
                                         Margin="5,2"
                                         IsReadOnly="True"
                                         d:LayoutOverrides="Width" />
                                <toolkit:Rating ItemCount="5"
                                                d:LayoutOverrides="Width, Height"
                                                Grid.Column="1"
                                                Grid.Row="6"
                                                Margin="5"
                                                IsReadOnly="True"
                                                Value="{Binding AverageRating}" />
                                <Rectangle Margin="5"
                                           Grid.RowSpan="6"
                                           Stroke="{StaticResource ColorAccentBrush}"
                                           RadiusX="3"
                                           RadiusY="3"
                                           Grid.Column="2"
                                           Width="110"
                                           Height="150"
                                           Fill="{StaticResource TreeViewItemSelectionBorder}"
                                           VerticalAlignment="Top" />
                                <TextBlock HorizontalAlignment="Center"
                                           TextWrapping="Wrap"
                                           Text="No Image"
                                           VerticalAlignment="Top"
                                           Foreground="{StaticResource ControlForeground}"
                                           Grid.Column="3"
                                           Grid.RowSpan="6"
                                           Margin="0,75,0,5" />
                                <Rectangle Margin="5"
                                           Grid.RowSpan="6"
                                           RadiusX="3"
                                           RadiusY="3"
                                           Grid.Column="2"
                                           Width="110"
                                           Height="150"
                                           Cursor="Hand"
                                           VerticalAlignment="Top">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="MouseLeftButtonUp">
                                            <cal:ActionMessage MethodName="OpenPicture" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                    <Rectangle.Fill>
                                        <ImageBrush Stretch="UniformToFill"
                                                    ImageSource="{Binding CurrentTitle.BoxArt.LargeUrl, Converter={StaticResource imageSourceConverter}}" />
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Grid>
                            <TextBlock TextWrapping="Wrap"
                                       Text="Genre"
                                       toolkit:DockPanel.Dock="Top"
                                       Style="{StaticResource Heading5}"
                                       Margin="5,15,5,5" />
                            <ListBox x:Name="Genres"
                                     ItemTemplate="{StaticResource TagItemTemplate}"
                                     ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                                     ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                     Style="{StaticResource InvisibleListBoxStyle}"
                                     toolkit:DockPanel.Dock="Top">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <cal:ActionMessage MethodName="OpenGenre">
                                            <cal:Parameter Value="{Binding SelectedItem, ElementName=Genres}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ListBox>
                        </toolkit:DockPanel>
                    </ScrollViewer>
                </sdk:TabItem>
                <sdk:TabItem Header="Synopsis"
                             d:LayoutOverrides="Width, Height">
                    <ScrollViewer Style="{StaticResource CustomScrollViewerStyle}"
                                  Margin="-5,-4">
                        <StackPanel>
                            <TextBox TextWrapping="Wrap"
                                     Text="{Binding Summary}"
                                     IsReadOnly="True"
                                     d:LayoutOverrides="Width, GridBox"
                                     FontWeight="Normal"
                                     VerticalScrollBarVisibility="Disabled" />
                            <TextBlock TextAlignment="Right"
                                       Foreground="{StaticResource ControlForeground}"
                                       d:LayoutOverrides="Width" />
                        </StackPanel>
                    </ScrollViewer>
                </sdk:TabItem>
                <sdk:TabItem Header="More..."
                             d:LayoutOverrides="Width, Height">
                    <ScrollViewer Style="{StaticResource CustomScrollViewerStyle}"
                                  Margin="-5,-4">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock TextWrapping="Wrap"
                                       Text="Director(s)"
                                       d:LayoutOverrides="Height"
                                       Margin="5"
                                       VerticalAlignment="Top" />
                            <TextBlock TextWrapping="Wrap"
                                       Text="Cast"
                                       Margin="5"
                                       VerticalAlignment="Top"
                                       Grid.Row="1" />
                            <TextBlock Grid.Row="2"
                                       TextWrapping="Wrap"
                                       Text="Languages"
                                       d:LayoutOverrides="Height"
                                       Margin="5"
                                       VerticalAlignment="Top" />
                            <TextBlock Grid.Row="3"
                                       TextWrapping="Wrap"
                                       Text="Awards"
                                       d:LayoutOverrides="Height"
                                       Margin="5"
                                       VerticalAlignment="Top" />
                            <ListBox x:Name="Directors"
                                     Grid.Column="1"
                                     Margin="5,2"
                                     Style="{StaticResource InvisibleListBoxStyle}"
                                     ItemTemplate="{StaticResource NameOnlyItemTemplate}"
                                     Padding="0">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <cal:ActionMessage MethodName="OpenPerson">
                                            <cal:Parameter Value="{Binding SelectedItem, ElementName=Directors}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ListBox>
                            <ListBox x:Name="Cast"
                                     Grid.Column="1"
                                     Margin="5,2"
                                     Style="{StaticResource InvisibleListBoxStyle}"
                                     ItemTemplate="{StaticResource NameOnlyItemTemplate}"
                                     Grid.Row="1"
                                     Padding="0">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <cal:ActionMessage MethodName="OpenPerson">
                                            <cal:Parameter Value="{Binding SelectedItem, ElementName=Cast}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ListBox>
                            <ListBox x:Name="Languages"
                                     Grid.Column="1"
                                     Margin="5,2"
                                     Grid.Row="2"
                                     Style="{StaticResource InvisibleListBoxStyle}"
                                     ItemTemplate="{StaticResource NameOnlyItemTemplate}"
                                     IsHitTestVisible="False"
                                     Padding="0"
                                     ItemsPanel="{StaticResource WrappingItemsPanelTemplate}" />
                            <ListBox x:Name="Awards"
                                     Grid.Column="1"
                                     Margin="5,2"
                                     Grid.Row="3"
                                     Style="{StaticResource InvisibleListBoxStyle}"
                                     ItemTemplate="{StaticResource AwardItemTemplate}"
                                     Padding="0" />
                        </Grid>
                    </ScrollViewer>
                </sdk:TabItem>
            </sdk:TabControl>
        </toolkit:DockPanel>
    </ctrl:WorkitemControl>
</UserControl>
